package ide.ccf.ccproject.managedbuilder;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;

public class AuthorityUI {
	static Table table_per;
	static Button b_network, b_ipc, b_x11, b_wayland, b_pulseaudio, b_sessionBus, b_systemBus,
	b_host, b_w_host, b_ro_host, b_home, b_w_home, b_ro_home, b_xdgdesktop, b_w_xdgdesktop,
	b_ro_xdgdesktop, b_xdgdocuments, b_w_xdgdocuments, b_ro_xdgdocuments, b_xdgdownload,
	b_w_xdgdownload, b_ro_xdgdownload, b_xdgmusic, b_w_xdgmusic, b_ro_xdgmusic, b_w_xdgpictures,
	b_xdgpictures, b_ro_xdgpictures, b_xdgpublicshare, b_w_xdgpublicshare, b_ro_xdgpublicshare, b_xdgtemplates,
	b_w_xdgtemplates, b_ro_xdgtemplates, b_xdgvideos, b_w_xdgvideos, b_ro_xdgvideos, b_absolutepath, b_w_absolutepath, b_ro_absolutepath
	;
	static Text t_path;
	private static String context;
	
	public AuthorityUI()
	{
		context = "";
	}
	@SuppressWarnings("unused")
	public void createAuthoritiesUI(Composite c_Per) {
		Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
		table_per= new Table(c_Per, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
		GridData gridData = new GridData(GridData.FILL_BOTH);
		gridData.minimumHeight = 200;
		gridData.heightHint = 0;
		table_per.setLayoutData(gridData);
		table_per.setLayout(new GridLayout(3, false));
		table_per.setBackground(color);
		Label name = new Label(table_per, SWT.NULL);
		name.setBackground(color);
		name.setText("访问权限会话套接字列表");
		
		Label l_1 = new Label(table_per, SWT.NULL);
		Label l_2 = new Label(table_per, SWT.NULL);
		
		b_network = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_network.setText("与主机系统共享网络命名空间");
		b_network.setData("network");
		b_network.setBackground(color);
		b_network.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		b_ipc = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_ipc.setText(" 与主机系统共享进程通讯命名空间");
		b_ipc.setData("ipc");
		b_ipc.setBackground(color);
		b_ipc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		b_x11 = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_x11.setText("使用X11显示窗口");
		b_x11.setData("x11");
		b_x11.setBackground(color);
		b_x11.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		b_wayland = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_wayland.setText("使用Wayland显示窗口");
		b_wayland.setData("wayland");
		b_wayland.setBackground(color);
		
		b_pulseaudio = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_pulseaudio.setText("使用PulseAudio播放声音");
		b_pulseaudio.setData("pulseaudio");
		b_pulseaudio.setBackground(color);
		
		b_sessionBus = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_sessionBus.setText("挂载到Session Bus");
		b_sessionBus.setData("session-bus");
		b_sessionBus.setBackground(color);
		
		b_systemBus = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_systemBus.setText("挂载到System Bus");
		b_systemBus.setData("system-bus");
		b_systemBus.setBackground(color);
		
		Label l_3 = new Label(table_per, SWT.NULL);
		Label l_4 = new Label(table_per, SWT.NULL);
		Label l_5= new Label(table_per, SWT.NULL);
		Label l_6 = new Label(table_per, SWT.NULL);
		Label l_7= new Label(table_per, SWT.NULL);
		
		Label nameF = new Label(table_per, SWT.NULL);
		nameF.setBackground(color);
		nameF.setText("可授予访问权限的主机系统文件");
		
		Label l_8 = new Label(table_per, SWT.NULL);
		Label l_9 = new Label(table_per, SWT.NULL);
		
		
		b_host = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_host.setText("允许访问所有主机文件");
		b_host.setData("host");
		b_host.setBackground(color);
		b_host.addSelectionListener(new SelectionListener(){

			public void widgetDefaultSelected(SelectionEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void widgetSelected(SelectionEvent e) {
				if(b_host.getSelection())
				{
					b_home.setEnabled(false);
					b_ro_home.setEnabled(false);
					b_w_home.setEnabled(false);
					b_xdgdesktop.setEnabled(false);
					b_w_xdgdesktop.setEnabled(false);
					b_ro_xdgdesktop.setEnabled(false);
					b_xdgdocuments.setEnabled(false);
					b_ro_xdgdocuments.setEnabled(false);
					b_w_xdgdocuments.setEnabled(false);
					b_xdgdownload.setEnabled(false);
					b_ro_xdgdownload.setEnabled(false);
					b_w_xdgdownload.setEnabled(false);
					b_xdgmusic.setEnabled(false);
					b_ro_xdgmusic.setEnabled(false);
					b_w_xdgmusic.setEnabled(false);
					b_xdgpictures.setEnabled(false);
					b_ro_xdgpictures.setEnabled(false);
					b_w_xdgpictures.setEnabled(false);
					b_xdgpublicshare.setEnabled(false);
					b_ro_xdgpublicshare.setEnabled(false);
					b_w_xdgpublicshare.setEnabled(false);
					b_xdgtemplates.setEnabled(false);
					b_ro_xdgtemplates.setEnabled(false);
					b_w_xdgtemplates.setEnabled(false);
					b_xdgvideos.setEnabled(false);
					b_ro_xdgvideos.setEnabled(false);
					b_w_xdgvideos.setEnabled(false);
					b_absolutepath.setEnabled(false);
					b_ro_absolutepath.setEnabled(false);
					b_w_absolutepath.setEnabled(false);
					t_path.setEnabled(false);
				}
				else
				{
					b_home.setEnabled(true);
					b_ro_home.setEnabled(true);
					b_w_home.setEnabled(true);
					b_xdgdesktop.setEnabled(true);
					b_w_xdgdesktop.setEnabled(true);
					b_ro_xdgdesktop.setEnabled(true);
					b_xdgdocuments.setEnabled(true);
					b_ro_xdgdocuments.setEnabled(true);
					b_w_xdgdocuments.setEnabled(true);
					b_xdgdownload.setEnabled(true);
					b_ro_xdgdownload.setEnabled(true);
					b_w_xdgdownload.setEnabled(true);
					b_xdgmusic.setEnabled(true);
					b_ro_xdgmusic.setEnabled(true);
					b_w_xdgmusic.setEnabled(true);
					b_xdgpictures.setEnabled(true);
					b_ro_xdgpictures.setEnabled(true);
					b_w_xdgpictures.setEnabled(true);
					b_xdgpublicshare.setEnabled(true);
					b_ro_xdgpublicshare.setEnabled(true);
					b_w_xdgpublicshare.setEnabled(true);
					b_xdgtemplates.setEnabled(true);
					b_ro_xdgtemplates.setEnabled(true);
					b_w_xdgtemplates.setEnabled(true);
					b_xdgvideos.setEnabled(true);
					b_ro_xdgvideos.setEnabled(true);
					b_w_xdgvideos.setEnabled(true);
					b_absolutepath.setEnabled(true);
					b_ro_absolutepath.setEnabled(true);
					b_w_absolutepath.setEnabled(true);
					t_path.setEnabled(true);
				}		
			}
		});
		
		Composite group_1 = new Composite(table_per, SWT.NONE);
		group_1.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_1.setLayout(new GridLayout(2, false));
		group_1.setBackground(color);
		
		b_w_host = new Button(group_1, SWT.RADIO | SWT.LEFT);
		b_w_host.setText("可写");
		b_w_host.setSelection(true);
		b_w_host.setBackground(color);
		
		b_ro_host = new Button(group_1, SWT.RADIO | SWT.LEFT);
		b_ro_host.setText("只读");
		b_ro_host.setBackground(color);
		
		Label l_10 = new Label(table_per, SWT.NULL);
		
		b_home = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_home.setText("允许完全访问用户主目录");
		b_home.setData("home");
		b_home.setBackground(color);
		b_home.addSelectionListener(new SelectionListener(){

			public void widgetDefaultSelected(SelectionEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void widgetSelected(SelectionEvent e) {
				if(b_home.getSelection())
				{
					b_host.setSelection(false);
					b_host.setEnabled(false);
					b_xdgdesktop.setEnabled(false);
					b_w_xdgdesktop.setEnabled(false);
					b_ro_xdgdesktop.setEnabled(false);
					b_xdgdocuments.setEnabled(false);
					b_ro_xdgdocuments.setEnabled(false);
					b_w_xdgdocuments.setEnabled(false);
					b_xdgdownload.setEnabled(false);
					b_ro_xdgdownload.setEnabled(false);
					b_w_xdgdownload.setEnabled(false);
					b_xdgmusic.setEnabled(false);
					b_ro_xdgmusic.setEnabled(false);
					b_w_xdgmusic.setEnabled(false);
					b_xdgpictures.setEnabled(false);
					b_ro_xdgpictures.setEnabled(false);
					b_w_xdgpictures.setEnabled(false);
					b_xdgpublicshare.setEnabled(false);
					b_ro_xdgpublicshare.setEnabled(false);
					b_w_xdgpublicshare.setEnabled(false);
					b_xdgtemplates.setEnabled(false);
					b_ro_xdgtemplates.setEnabled(false);
					b_w_xdgtemplates.setEnabled(false);
					b_xdgvideos.setEnabled(false);
					b_ro_xdgvideos.setEnabled(false);
					b_w_xdgvideos.setEnabled(false);
					b_absolutepath.setEnabled(false);
					b_ro_absolutepath.setEnabled(false);
					b_w_absolutepath.setEnabled(false);
					t_path.setEnabled(false);
				}
				else
				{
					b_host.setEnabled(true);
					b_xdgdesktop.setEnabled(true);
					b_w_xdgdesktop.setEnabled(true);
					b_ro_xdgdesktop.setEnabled(true);
					b_xdgdocuments.setEnabled(true);
					b_ro_xdgdocuments.setEnabled(true);
					b_w_xdgdocuments.setEnabled(true);
					b_xdgdownload.setEnabled(true);
					b_ro_xdgdownload.setEnabled(true);
					b_w_xdgdownload.setEnabled(true);
					b_xdgmusic.setEnabled(true);
					b_ro_xdgmusic.setEnabled(true);
					b_w_xdgmusic.setEnabled(true);
					b_xdgpictures.setEnabled(true);
					b_ro_xdgpictures.setEnabled(true);
					b_w_xdgpictures.setEnabled(true);
					b_xdgpublicshare.setEnabled(true);
					b_ro_xdgpublicshare.setEnabled(true);
					b_w_xdgpublicshare.setEnabled(true);
					b_xdgtemplates.setEnabled(true);
					b_ro_xdgtemplates.setEnabled(true);
					b_w_xdgtemplates.setEnabled(true);
					b_xdgvideos.setEnabled(true);
					b_ro_xdgvideos.setEnabled(true);
					b_w_xdgvideos.setEnabled(true);
					b_absolutepath.setEnabled(true);
					b_ro_absolutepath.setEnabled(true);
					b_w_absolutepath.setEnabled(true);
					t_path.setEnabled(true);
				}
			}
			
		});
		
		Composite group_2 = new Composite(table_per, SWT.NONE);
		group_2.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_2.setLayout(new GridLayout(2, false));
		group_2.setBackground(color);
		
		b_w_home = new Button(group_2, SWT.RADIO | SWT.LEFT);
		b_w_home.setText("可写");
		b_w_home.setSelection(true);
		b_w_home.setBackground(color);
		
		b_ro_home = new Button(group_2, SWT.RADIO | SWT.LEFT);
		b_ro_home.setText("只读");
		b_ro_home.setBackground(color);
		
		Label l_11 = new Label(table_per, SWT.NULL);
		
		b_xdgdesktop = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgdesktop.setText("允许访问用户桌面目录");
		b_xdgdesktop.setData("xdg-desktop");
		b_xdgdesktop.setBackground(color);
		
		Composite group_3 = new Composite(table_per, SWT.NONE);
		group_3.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_3.setLayout(new GridLayout(2, false));
		group_3.setBackground(color);
		
		b_w_xdgdesktop = new Button(group_3, SWT.RADIO | SWT.LEFT);
		b_w_xdgdesktop.setText("可写");
		b_w_xdgdesktop.setSelection(true);
		b_w_xdgdesktop.setBackground(color);
		
		b_ro_xdgdesktop = new Button(group_3, SWT.RADIO | SWT.LEFT);
		b_ro_xdgdesktop.setText("只读");
		b_ro_xdgdesktop.setBackground(color);
		
		Label l_12 = new Label(table_per, SWT.NULL);
		
		b_xdgdocuments = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgdocuments.setText("允许访问用户文档目录");
		b_xdgdocuments.setData("xdg-documents");
		b_xdgdocuments.setBackground(color);
		
		Composite group_4 = new Composite(table_per, SWT.NONE);
		group_4.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_4.setLayout(new GridLayout(2, false));
		group_4.setBackground(color);
		
		b_w_xdgdocuments = new Button(group_4, SWT.RADIO | SWT.LEFT);
		b_w_xdgdocuments.setText("可写");
		b_w_xdgdocuments.setSelection(true);
		b_w_xdgdocuments.setBackground(color);
		
		b_ro_xdgdocuments = new Button(group_4, SWT.RADIO | SWT.LEFT);
		b_ro_xdgdocuments.setText("只读");
		b_ro_xdgdocuments.setBackground(color);
		
		Label l_13 = new Label(table_per, SWT.NULL);
		
		b_xdgdownload = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgdownload.setText("允许访问用户下载目录");
		b_xdgdownload.setData("xdg-download");
		b_xdgdownload.setBackground(color);
		
		Composite group_5 = new Composite(table_per, SWT.NONE);
		group_5.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_5.setLayout(new GridLayout(2, false));
		group_5.setBackground(color);
		
		b_w_xdgdownload = new Button(group_5, SWT.RADIO | SWT.LEFT);
		b_w_xdgdownload.setText("可写");
		b_w_xdgdownload.setSelection(true);
		b_w_xdgdownload.setBackground(color);
		
		b_ro_xdgdownload = new Button(group_5, SWT.RADIO | SWT.LEFT);
		b_ro_xdgdownload.setText("只读");
		b_ro_xdgdownload.setBackground(color);
		
		Label l_14 = new Label(table_per, SWT.NULL);
		
		b_xdgmusic = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgmusic.setText("允许访问用户音乐目录");
		b_xdgmusic.setData("xdg-music");
		b_xdgmusic.setBackground(color);
		
		Composite group_6 = new Composite(table_per, SWT.NONE);
		group_6.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_6.setLayout(new GridLayout(2, false));
		group_6.setBackground(color);
		
		b_w_xdgmusic = new Button(group_6, SWT.RADIO | SWT.LEFT);
		b_w_xdgmusic.setText("可写");
		b_w_xdgmusic.setSelection(true);
		b_w_xdgmusic.setBackground(color);
		
		b_ro_xdgmusic = new Button(group_6, SWT.RADIO | SWT.LEFT);
		b_ro_xdgmusic.setText("只读");
		b_ro_xdgmusic.setBackground(color);
		
		Label l_15 = new Label(table_per, SWT.NULL);
		
		b_xdgpictures = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgpictures.setText("允许访问用户图片目录");
		b_xdgpictures.setData("xdg-pictures");
		b_xdgpictures.setBackground(color);
		
		Composite group_7 = new Composite(table_per, SWT.NONE);
		group_7.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_7.setLayout(new GridLayout(2, false));
		group_7.setBackground(color);
		
		b_w_xdgpictures = new Button(group_7, SWT.RADIO | SWT.LEFT);
		b_w_xdgpictures.setText("可写");
		b_w_xdgpictures.setSelection(true);
		b_w_xdgpictures.setBackground(color);
		
		b_ro_xdgpictures = new Button(group_7, SWT.RADIO | SWT.LEFT);
		b_ro_xdgpictures.setText("只读");
		b_ro_xdgpictures.setBackground(color);
		
		Label l_16 = new Label(table_per, SWT.NULL);
		
		b_xdgpublicshare = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgpublicshare.setText("允许访问用户共享目录");
		b_xdgpublicshare.setData("xdg-public-share");
		b_xdgpublicshare.setBackground(color);
		
		Composite group_8 = new Composite(table_per, SWT.NONE);
		group_8.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_8.setLayout(new GridLayout(2, false));
		group_8.setBackground(color);
		
		b_w_xdgpublicshare = new Button(group_8, SWT.RADIO | SWT.LEFT);
		b_w_xdgpublicshare.setText("可写");
		b_w_xdgpublicshare.setSelection(true);
		b_w_xdgpublicshare.setBackground(color);
		
		b_ro_xdgpublicshare = new Button(group_8, SWT.RADIO | SWT.LEFT);
		b_ro_xdgpublicshare.setText("只读");
		b_ro_xdgpublicshare.setBackground(color);
		
		Label l_17 = new Label(table_per, SWT.NULL);
		
		b_xdgtemplates = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgtemplates.setText("允许访问用户模板目录");
		b_xdgtemplates.setData("xdg-templates");
		b_xdgtemplates.setBackground(color);
		
		Composite group_9 = new Composite(table_per, SWT.NONE);
		group_9.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_9.setLayout(new GridLayout(2, false));
		group_9.setBackground(color);
		
		b_w_xdgtemplates = new Button(group_9, SWT.RADIO | SWT.LEFT);
		b_w_xdgtemplates.setText("可写");
		b_w_xdgtemplates.setSelection(true);
		b_w_xdgtemplates.setBackground(color);
		
		b_ro_xdgtemplates = new Button(group_9, SWT.RADIO | SWT.LEFT);
		b_ro_xdgtemplates.setText("只读");
		b_ro_xdgtemplates.setBackground(color);
		
		Label l_18 = new Label(table_per, SWT.NULL);
		
		b_xdgvideos = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgvideos.setText("允许访问用户视频目录");
		b_xdgvideos.setData("xdg-videos");
		b_xdgvideos.setBackground(color);
		
		Composite group_10 = new Composite(table_per, SWT.NONE);
		group_10.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_10.setLayout(new GridLayout(2, false));
		group_10.setBackground(color);
		
		b_w_xdgvideos = new Button(group_10, SWT.RADIO | SWT.LEFT);
		b_w_xdgvideos.setText("可写");
		b_w_xdgvideos.setSelection(true);
		b_w_xdgvideos.setBackground(color);
		
		b_ro_xdgvideos = new Button(group_10, SWT.RADIO | SWT.LEFT);
		b_ro_xdgvideos.setText("只读");
		b_ro_xdgvideos.setBackground(color);
		
		Label l_19 = new Label(table_per, SWT.NULL);
		
/*		Button b_xdgrun = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_xdgrun.setText("xdg-run");
		b_xdgrun.setData("xdg-run");
		b_xdgrun.setBackground(color);
		
		Composite group_11 = new Composite(table_per, SWT.NONE);
		group_11.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_11.setLayout(new GridLayout(2, false));
		group_11.setBackground(color);
		
		Button b_w_xdgrun = new Button(group_11, SWT.RADIO | SWT.LEFT);
		b_w_xdgrun.setText("可写");
		b_w_xdgrun.setSelection(true);
		b_w_xdgrun.setBackground(color);
		
		Button b_ro_xdgrun = new Button(group_11, SWT.RADIO | SWT.LEFT);
		b_ro_xdgrun.setText("只读");
		b_ro_xdgrun.setBackground(color);
		
		Label l_20 = new Label(table_per, SWT.NULL);	*/
		
		b_absolutepath = new Button(table_per, SWT.CHECK | SWT.LEFT);
		b_absolutepath.setText("允许访问绝对目录/相对目录");
		b_absolutepath.setData("path");
		b_absolutepath.setBackground(color);
		
		
		t_path  = new Text(table_per, SWT.BORDER);
		t_path.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		t_path.setText("");
		t_path.setEnabled(false);
		
		b_absolutepath.addSelectionListener(new SelectionListener(){
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void widgetSelected(SelectionEvent e) {
				if(b_absolutepath.getSelection())
					t_path.setEnabled(true);
				else
				{
					t_path.setText("");
					t_path.setEnabled(false);
				}			
		}
		});
		
		Composite group_12 = new Composite(table_per, SWT.NONE);
		group_12.setLayoutData(new GridData(GridData.FILL_BOTH));
		group_12.setLayout(new GridLayout(2, false));
		group_12.setBackground(color);
		
		b_w_absolutepath = new Button(group_12, SWT.RADIO | SWT.LEFT);
		b_w_absolutepath.setText("可写");
		b_w_absolutepath.setSelection(true);
		b_w_absolutepath.setBackground(color);
		
		b_ro_absolutepath = new Button(group_12, SWT.RADIO | SWT.LEFT);
		b_ro_absolutepath.setText("只读");
		b_ro_absolutepath.setBackground(color);
		
	}
	
	public String getCheckedElements()
	{
		context = "";
		if(b_network.getSelection())
			context += b_network.getData().toString() + ";";
		if(b_ipc.getSelection())
			context += b_ipc.getData().toString() + ";";
		if(b_x11.getSelection())
			context += b_x11.getData().toString() + ";";
		if(b_wayland.getSelection())
			context += b_wayland.getData().toString() + ";";
		if(b_pulseaudio.getSelection())
			context += b_pulseaudio.getData().toString() + ";";
		if(b_sessionBus.getSelection())
			context += b_sessionBus.getData().toString() + ";";
		if(b_systemBus.getSelection())
			context += b_systemBus.getData().toString() + ";";
		if(b_host.getSelection())
		{
			if(b_w_host.getSelection())
				context += b_host.getData().toString() + ";";
			else
				context += b_host.getData().toString() +":ro;";
		}
		else
		{
			if(b_home.getSelection())
			{
				if(b_w_home.getSelection())
					context += b_home.getData().toString() + ";";
				else
					context += b_home.getData().toString() +":ro;";
			}
			else
			{
				if(b_xdgdesktop.getSelection())
				{
					if(b_w_xdgdesktop.getSelection())
						context += b_xdgdesktop.getData().toString() + ";";
					else
						context += b_xdgdesktop.getData().toString() +":ro;";
				}
				if(b_xdgdocuments.getSelection())
				{
					if(b_w_xdgdocuments.getSelection())
						context += b_xdgdocuments.getData().toString() + ";";
					else
						context += b_xdgdocuments.getData().toString() +":ro;";
				}
				if(b_xdgdownload.getSelection())
				{
					if(b_w_xdgdownload.getSelection())
						context += b_xdgdownload.getData().toString() + ";";
					else
						context += b_xdgdownload.getData().toString() +":ro;";
				}
				if(b_xdgmusic.getSelection())
				{
					if(b_w_xdgmusic.getSelection())
						context += b_xdgmusic.getData().toString() + ";";
					else
						context += b_xdgmusic.getData().toString() +":ro;";
				}
				if(b_xdgpictures.getSelection())
				{
					if(b_w_xdgpictures.getSelection())
						context += b_xdgpictures.getData().toString() + ";";
					else
						context += b_xdgpictures.getData().toString() +":ro;";
				}
				if(b_xdgpublicshare.getSelection())
				{
					if(b_w_xdgpublicshare.getSelection())
						context += b_xdgpublicshare.getData().toString() + ";";
					else
						context += b_xdgpublicshare.getData().toString() +":ro;";
				}
				if(b_xdgtemplates.getSelection())
				{
					if(b_w_xdgtemplates.getSelection())
						context += b_xdgtemplates.getData().toString() + ";";
					else
						context += b_xdgtemplates.getData().toString() +":ro;";
				}
				if(b_xdgvideos.getSelection())
				{
					if(b_w_xdgvideos.getSelection())
						context += b_xdgvideos.getData().toString() + ";";
					else
						context += b_xdgvideos.getData().toString() +":ro;";
				}
				if(b_absolutepath.getSelection())
				{
					if(b_w_absolutepath.getSelection())
						context += t_path.getText() + ";";
					else
						context += t_path.getText() +":ro;";
				}
			}
		}
		return context;
	}
	
	public void setAuthoritiesUI(String[] strAuthorities)
	{
		int length = strAuthorities.length;
		for(int i = 0; i < length; i++)
		{
			setUI(strAuthorities[i]);
		}
	}
	
	private void setUI(String string) {
		if(string.equals("network"))
			b_network.setSelection(true);
		else if(string.equals("ipc"))
			b_ipc.setSelection(true);
		else if(string.equals("x11"))
			b_x11.setSelection(true);
		else if(string.equals("wayland"))
			b_wayland.setSelection(true);
		else if(string.equals("pulseaudio"))
			b_pulseaudio.setSelection(true);
		else if(string.equals("session-bus"))
			b_sessionBus.setSelection(true);
		else if(string.equals("system-bus"))
			b_systemBus.setSelection(true);
		else if(string.equals("host"))
		{
			b_host.setSelection(true);
			b_w_host.setSelection(true);
			b_ro_host.setSelection(false);
		}
		else if(string.equals("host:ro"))
		{
			b_host.setSelection(true);
			b_ro_host.setSelection(true);
			b_w_host.setSelection(false);
		}
		else if(string.equals("home"))
		{
			b_home.setSelection(true);
			b_w_home.setSelection(true);
			b_ro_home.setSelection(false);
		}
		else if(string.equals("home:ro"))
		{
			b_home.setSelection(true);
			b_ro_home.setSelection(true);
			b_w_home.setSelection(false);
		}
		else if(string.equals("xdg-desktop"))
		{
			b_xdgdesktop.setSelection(true);
			b_w_xdgdesktop.setSelection(true);
			b_ro_xdgdesktop.setSelection(false);
		}
		else if(string.equals("xdg-desktop:ro"))
		{
			b_xdgdesktop.setSelection(true);
			b_ro_xdgdesktop.setSelection(true);
			b_w_xdgdesktop.setSelection(false);
		}
		else if(string.equals("xdg-documents"))
		{
			b_xdgdocuments.setSelection(true);
			b_w_xdgdocuments.setSelection(true);
			b_ro_xdgdocuments.setSelection(false);
		}
		else if(string.equals("xdg-documents:ro"))
		{
			b_xdgdocuments.setSelection(true);
			b_ro_xdgdocuments.setSelection(true);
			b_w_xdgdocuments.setSelection(false);
		}
		else if(string.equals("xdg-download"))
		{
			b_xdgdownload.setSelection(true);
			b_w_xdgdownload.setSelection(true);
			b_ro_xdgdownload.setSelection(false);
		}
		else if(string.equals("xdg-download:ro"))
		{
			b_xdgdownload.setSelection(true);
			b_ro_xdgdownload.setSelection(true);
			b_w_xdgdownload.setSelection(false);
		}
		else if(string.equals("xdg-music"))
		{
			b_xdgmusic.setSelection(true);
			b_w_xdgmusic.setSelection(true);
			b_ro_xdgmusic.setSelection(false);
		}
		else if(string.equals("xdg-music:ro"))
		{
			b_xdgmusic.setSelection(true);
			b_ro_xdgmusic.setSelection(true);
			b_w_xdgmusic.setSelection(false);
		}
		else if(string.equals("xdg-pictures"))
		{
			b_xdgpictures.setSelection(true);
			b_w_xdgpictures.setSelection(true);
			b_ro_xdgpictures.setSelection(false);
		}
		else if(string.equals("xdg-pictures:ro"))
		{
			b_xdgpictures.setSelection(true);
			b_ro_xdgpictures.setSelection(true);
			b_w_xdgpictures.setSelection(false);
		}
		else if(string.equals("xdg-public-share"))
		{
			b_xdgpublicshare.setSelection(true);
			b_w_xdgpublicshare.setSelection(true);
			b_ro_xdgpublicshare.setSelection(false);
		}
		else if(string.equals("xdg-public-share:ro"))
		{
			b_xdgpublicshare.setSelection(true);
			b_ro_xdgpublicshare.setSelection(true);
			b_w_xdgpublicshare.setSelection(false);
		}
		else if(string.equals("xdg-templates"))
		{
			b_xdgtemplates.setSelection(true);
			b_w_xdgtemplates.setSelection(true);
			b_ro_xdgtemplates.setSelection(false);
		}
		else if(string.equals("xdg-templates:ro"))
		{
			b_xdgtemplates.setSelection(true);
			b_ro_xdgtemplates.setSelection(true);
			b_w_xdgtemplates.setSelection(false);
		}
		else if(string.equals("xdg-videos"))
		{
			b_xdgvideos.setSelection(true);
			b_w_xdgvideos.setSelection(true);
			b_ro_xdgvideos.setSelection(false);
		}
		else if(string.equals("xdg-videos:ro"))
		{
			b_xdgvideos.setSelection(true);
			b_ro_xdgvideos.setSelection(true);
			b_w_xdgvideos.setSelection(false);
		}
	}
	
	public void setCheckedElements()
	{
		if(b_host.getSelection())
		{
			b_home.setSelection(false);
			b_home.setEnabled(false);
			b_ro_home.setEnabled(false);
			b_w_home.setEnabled(false);
			b_xdgdesktop.setSelection(false);
			b_xdgdesktop.setEnabled(false);
			b_w_xdgdesktop.setEnabled(false);
			b_ro_xdgdesktop.setEnabled(false);
			b_xdgdocuments.setSelection(false);
			b_xdgdocuments.setEnabled(false);
			b_ro_xdgdocuments.setEnabled(false);
			b_w_xdgdocuments.setEnabled(false);
			b_xdgdownload.setSelection(false);
			b_xdgdownload.setEnabled(false);
			b_ro_xdgdownload.setEnabled(false);
			b_w_xdgdownload.setEnabled(false);
			b_xdgmusic.setSelection(false);
			b_xdgmusic.setEnabled(false);
			b_ro_xdgmusic.setEnabled(false);
			b_w_xdgmusic.setEnabled(false);
			b_xdgpictures.setSelection(false);
			b_xdgpictures.setEnabled(false);
			b_ro_xdgpictures.setEnabled(false);
			b_w_xdgpictures.setEnabled(false);
			b_xdgpublicshare.setSelection(false);
			b_xdgpublicshare.setEnabled(false);
			b_ro_xdgpublicshare.setEnabled(false);
			b_w_xdgpublicshare.setEnabled(false);
			b_xdgtemplates.setSelection(false);
			b_xdgtemplates.setEnabled(false);
			b_ro_xdgtemplates.setEnabled(false);
			b_w_xdgtemplates.setEnabled(false);
			b_xdgvideos.setSelection(false);
			b_xdgvideos.setEnabled(false);
			b_ro_xdgvideos.setEnabled(false);
			b_w_xdgvideos.setEnabled(false);
			b_absolutepath.setSelection(false);
			b_absolutepath.setEnabled(false);
			b_ro_absolutepath.setEnabled(false);
			b_w_absolutepath.setEnabled(false);
			t_path.setEnabled(false);
		}
		else 
		{
			b_home.setEnabled(true);
			b_ro_home.setEnabled(true);
			b_w_home.setEnabled(true);
			b_xdgdesktop.setEnabled(true);
			b_w_xdgdesktop.setEnabled(true);
			b_ro_xdgdesktop.setEnabled(true);
			b_xdgdocuments.setEnabled(true);
			b_ro_xdgdocuments.setEnabled(true);
			b_w_xdgdocuments.setEnabled(true);
			b_xdgdownload.setEnabled(true);
			b_ro_xdgdownload.setEnabled(true);
			b_w_xdgdownload.setEnabled(true);
			b_xdgmusic.setEnabled(true);
			b_ro_xdgmusic.setEnabled(true);
			b_w_xdgmusic.setEnabled(true);
			b_xdgpictures.setEnabled(true);
			b_ro_xdgpictures.setEnabled(true);
			b_w_xdgpictures.setEnabled(true);
			b_xdgpublicshare.setEnabled(true);
			b_ro_xdgpublicshare.setEnabled(true);
			b_w_xdgpublicshare.setEnabled(true);
			b_xdgtemplates.setEnabled(true);
			b_ro_xdgtemplates.setEnabled(true);
			b_w_xdgtemplates.setEnabled(true);
			b_xdgvideos.setEnabled(true);
			b_ro_xdgvideos.setEnabled(true);
			b_w_xdgvideos.setEnabled(true);
			b_absolutepath.setEnabled(true);
			b_ro_absolutepath.setEnabled(true);
			b_w_absolutepath.setEnabled(true);
			t_path.setEnabled(true);
		}
		
		if(b_home.getSelection())
		{
			b_host.setSelection(false);
			b_host.setEnabled(false);
			b_xdgdesktop.setSelection(false);
			b_xdgdesktop.setEnabled(false);
			b_w_xdgdesktop.setEnabled(false);
			b_ro_xdgdesktop.setEnabled(false);
			b_xdgdocuments.setSelection(false);
			b_xdgdocuments.setEnabled(false);
			b_ro_xdgdocuments.setEnabled(false);
			b_w_xdgdocuments.setEnabled(false);
			b_xdgdownload.setSelection(false);
			b_xdgdownload.setEnabled(false);
			b_ro_xdgdownload.setEnabled(false);
			b_w_xdgdownload.setEnabled(false);
			b_xdgmusic.setSelection(false);
			b_xdgmusic.setEnabled(false);
			b_ro_xdgmusic.setEnabled(false);
			b_w_xdgmusic.setEnabled(false);
			b_xdgpictures.setSelection(false);
			b_xdgpictures.setEnabled(false);
			b_ro_xdgpictures.setEnabled(false);
			b_w_xdgpictures.setEnabled(false);
			b_xdgpublicshare.setSelection(false);
			b_xdgpublicshare.setEnabled(false);
			b_ro_xdgpublicshare.setEnabled(false);
			b_w_xdgpublicshare.setEnabled(false);
			b_xdgtemplates.setSelection(false);
			b_xdgtemplates.setEnabled(false);
			b_ro_xdgtemplates.setEnabled(false);
			b_w_xdgtemplates.setEnabled(false);
			b_xdgvideos.setSelection(false);
			b_xdgvideos.setEnabled(false);
			b_ro_xdgvideos.setEnabled(false);
			b_w_xdgvideos.setEnabled(false);
			b_absolutepath.setSelection(false);
			b_absolutepath.setEnabled(false);
			b_ro_absolutepath.setEnabled(false);
			b_w_absolutepath.setEnabled(false);
			t_path.setText("");
			t_path.setEnabled(false);
		}
		else
		{
			b_host.setEnabled(true);
			if(!b_host.getSelection())
			{
				b_xdgdesktop.setEnabled(true);
				b_w_xdgdesktop.setEnabled(true);
				b_ro_xdgdesktop.setEnabled(true);
				b_xdgdocuments.setEnabled(true);
				b_ro_xdgdocuments.setEnabled(true);
				b_w_xdgdocuments.setEnabled(true);
				b_xdgdownload.setEnabled(true);
				b_ro_xdgdownload.setEnabled(true);
				b_w_xdgdownload.setEnabled(true);
				b_xdgmusic.setEnabled(true);
				b_ro_xdgmusic.setEnabled(true);
				b_w_xdgmusic.setEnabled(true);
				b_xdgpictures.setEnabled(true);
				b_ro_xdgpictures.setEnabled(true);
				b_w_xdgpictures.setEnabled(true);
				b_xdgpublicshare.setEnabled(true);
				b_ro_xdgpublicshare.setEnabled(true);
				b_w_xdgpublicshare.setEnabled(true);
				b_xdgtemplates.setEnabled(true);
				b_ro_xdgtemplates.setEnabled(true);
				b_w_xdgtemplates.setEnabled(true);
				b_xdgvideos.setEnabled(true);
				b_ro_xdgvideos.setEnabled(true);
				b_w_xdgvideos.setEnabled(true);
				b_absolutepath.setEnabled(true);
				b_ro_absolutepath.setEnabled(true);
				b_w_absolutepath.setEnabled(true);
				t_path.setEnabled(true);
			}
		}
	}
	public void setDefaultValue() {
		b_network.setSelection(true);
		b_ipc.setSelection(true);
		b_x11.setSelection(true);
		b_wayland.setSelection(true);
		b_pulseaudio.setSelection(true);
		b_sessionBus.setSelection(true);
		b_systemBus.setSelection(true);
		b_host.setSelection(true);
	}
	public void setAllChecked(boolean b) {
		b_network.setSelection(b);
		b_ipc.setSelection(b);
		b_x11.setSelection(b);
		b_wayland.setSelection(b);
		b_pulseaudio.setSelection(b);
		b_sessionBus.setSelection(b);
		b_systemBus.setSelection(b);
		b_host.setSelection(b);
		setCheckedElements();
		if(b == false)
		{
			b_home.setSelection(b);
			b_xdgdesktop.setSelection(b);
			b_xdgdocuments.setSelection(b);
			b_xdgdownload.setSelection(b);
			b_xdgmusic.setSelection(b);
			b_xdgpictures.setSelection(b);
			b_xdgpublicshare.setSelection(b);
			b_xdgtemplates.setSelection(b);
			b_xdgvideos.setSelection(b);
			b_absolutepath.setSelection(b);
			t_path.setEnabled(false);
		}
		
	}
}
